<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateYRanksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('y_ranks')) {
            Schema::create('y_ranks', function (Blueprint $table) {
                $table->engine = 'MyISAM';
                $table->increments('rank_id');
                $table->integer('rank_number')->default(0)->comment('等级的第几级');
                $table->string('rank_thumbnail')->default('')->comment('等级图标');
                $table->string('rank_name', 30)->default('')->comment('等级名称');
                $table->boolean('rank_type')->default(0)->comment('等级类型，1用户等级，2图片等级');
                $table->boolean('rank_status')->default(1)->comment('等级状态，1正常，2停用');
                $table->integer('rank_health_point')->default(0)->comment('送血量');
                $table->integer('rank_prop_id')->default(0)->comment('送道具');
                $table->boolean('rank_condition_type')->default(0)->comment('到此等级的类型，1次数，2百分比');
                $table->integer('rank_condition')->default(0)->comment('到此等级的条件');
                $table->timestamps();

                //索引
                $table->index('rank_name');
                $table->index('rank_type');
                $table->index('rank_status');
                $table->index('rank_condition_type');
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('y_ranks');
    }
}
